package com.xingda.packing.dmss.rule.check;

import com.xingda.packing.dmss.domain.ProductBox;
import org.springframework.stereotype.Component;

/**
 * 同机床轮数
 *
 * @author LEGION
 */
@Component
public class SameMachineNumCheck implements PackRuleCheckService {
    @Override
    public boolean inspect(ProductBox productBox) {

        if (productBox.getType() == 2) {
            return true;
        }

        if (productBox.getType() == 5) {
            return true;
        }
        //如果没开启
        if (!productBox.getPackDemand().getFloorSameMachineNum().isEnable()) {
            return true;
        }

        return productBox.floorSameMachineNum().values().stream().allMatch(num -> num <= productBox.getPackDemand().getFloorSameMachineNum().getMax().intValue());
    }

}
